﻿using System.Xml.Linq;

namespace Silent.API.LastFm.Requests
{
    public class AlbumInfoRequest : RequestBase<Album>
    {
        public AlbumInfoRequest(string apiKey, string artist, string album)
            : base(apiKey, QueryConstants.ALBUM_GET_INFO)
        {
            parameters.AddRange(new[] {
                new QueryParameter(QueryConstants.PREFIX_ARTIST, artist),
                new QueryParameter(QueryConstants.PREFIX_ALBUM, album)
            });
        }

        public override Album Request()
        {
            var query = new QueryBuilder().BuildQuery(parameters.ToArray());
            var element = XElement.Load(query).Element("album");
            var objects = Converter.ConvertToAlbum(element);
            return objects;
        }
    }
}
